Fix stale state in callbacks when multiple events fire rapidly#3963
Open
Madoshakalaka wants to merge 2 commits intomasterfrom
Open
Fix stale state in callbacks when multiple events fire rapidly#3963Madoshakalaka wants to merge 2 commits intomasterfrom
Madoshakalaka wants to merge 2 commits intomasterfrom
Conversation
Benchmark - coreYew MasterPull Request |
|
Visit the preview URL for this PR (updated for commit 6f0b966): https://yew-rs--pr3963-fix-stale-state-issu-iujte35q.web.app (expires Fri, 26 Dec 2025 04:49:27 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 |
Size ComparisonDetails
✅ None of the examples has changed their size significantly. |
e895a14 to
b53017d
Compare
Benchmark - SSRYew MasterDetails
Pull RequestDetails
|
ad26d0b to
6f0b966
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The UseReducerHandle was caching a snapshot of state at render time.
When set() was called, the underlying RefCell was updated, but callback
closures still held handles pointing to old snapshots. This caused
stale state reads when multiple events fired before a rerender.
The fix changes UseReducerHandle to:
This ensures callbacks see the latest state in normal operation while
avoiding panics when state is read during reducer execution (e.g., SSR).
Changes:
Fixes #3796
Checklist